Skip to content

fix: size max_threads auto from the memory limit of the container, not of the host - #2878

Merged
dunglas merged 4 commits into
php:mainfrom
nicolas-grekas:max-threads-memory-limit
Dec 2, 2026
Merged

dunglas merged 4 commits into
php:mainfrom
nicolas-grekas:max-threads-memory-limit

Conversation

@nicolas-grekas

Copy link
Copy Markdown
Contributor

In a container, sysinfo reports the memory of the host: max_threads auto then lets a container of a few hundred MB on a big host run hundreds of threads, enough to get it killed under load.

auto now uses the memory limit of Go when it's lower than the system's. Caddy derives it from the cgroup of the container, and GOMEMLIMIT sets it where the container doesn't expose one, as on Platform.sh and Upsun.

nicolas-grekas and others added 4 commits November 26, 2026 10:38
…t of the host

In a container, sysinfo reports the memory of the host: max_threads auto
then allowed hundreds of threads to a container of a few hundred MB. The
memory limit of Go caps it now when lower, which Caddy derives from the
cgroup of the container, and GOMEMLIMIT sets when the container doesn't
expose one.
Like "caddy run", php-server now derives GOMEMLIMIT from the cgroup or the system memory, which max_threads auto relies on.
Caddy sets the Go memory limit to 90% of the RAM even when FrankenPHP cannot read the system memory, so only an explicit GOMEMLIMIT is honored there. Tests no longer assume the host has more memory than the limit under test.
The debug log reported the memory-based estimate even when it was below num_threads, while the effective limit was num_threads.
@dunglas
dunglas merged commit 49b8dff into php:main Dec 2, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants